<template>
    <div class="accountsetting">
        <page-title>账户设置</page-title>
        <div class="content-box"> 
          <div class="input-box">
            <span class="item-name">用户名：</span>
            <el-input disabled v-model="form.admin_account"></el-input>
          </div> 
          <!--<div class="input-box">
            <span class="item-name">旧密码：</span>
            <el-input v-model="oldPassword" type="password"></el-input>
          </div>-->
          <div class="input-box">
            <span class="item-name">新密码：</span>
            <el-input v-model="form.newPassword" type="password"></el-input>
          </div>
          <div class="input-box">
            <span class="item-name">确认密码：</span>
            <el-input v-model="form.confirmPassword" type="password"></el-input>
          </div>
          <div class="btn-box">
            <el-button type="primary" @click="submit">提交</el-button>
          </div>
        </div>
    </div>
</template>
<script>
import * as api from '../../../api/api'
import { Message } from 'element-ui'
export default {
    name: 'accountsetting',
    data () {
        return { 
          form:{
            admin_account:sessionStorage.getItem('username'),
            newPassword: '',
            confirmPassword: '',
          }, 
            
        }
    },
    created() { 
       
    },
    methods: {
         
        //提交修改信息
        submit(){
          var that = this; 
          if (!that.form.newPassword) {
            Message({
                message: '请输入新密码',
                type: 'info',
                duration: 1000
            });
            return;
          } else if (!that.form.confirmPassword) {
            Message({
                message: '请再次输入新密码',
                type: 'info',
                duration: 1000
            });
            return;
          } else if (that.form.newPassword != that.form.confirmPassword) {
            Message({
                message: '两次输入新密码不一样',
                type: 'info',
                duration: 1000
            });
            return;
          }
          api.alterPassword({
            password:that.form.newPassword
          }).then(res => {
            if (res.data.code == 300000) {
              Message({
                  message: '修改成功',
                  type: 'success',
                  duration: 1000
              });
              that.$router.back(-1);
            }
          })
        }, 
    },
    components: {

    }
}
</script>
<style>
   .accountsetting .el-input {
     width:200px;
   }
</style>
<style scoped lang="scss">
    .accountsetting {
        background: #ffffff;
        min-height: 100%;
        position: relative;
        box-sizing:border-box;
        color: #666666;
        font-size: 14px;
        .content-box{
          margin-top:80px;
        }
        .input-box {
          width: 330px;
          margin: 0 auto 10px;
          .item-name {
            width: 100px;
            display: inline-block;
            color: #666666;
            font-size: 12px;
            text-align: right;
            padding-right: 5px;
          }
          .item-name:before {
            content: '*';
            color: #F04844;
          }
        }
        .btn-box{
          text-align: center;
          margin-top: 30px;
        }
    }
</style>
